using System;
using flickr.api;

namespace FlickrShots.Framework
{
    /// <summary>
    /// Downloads an image from Flickr and creates a new Wallpapr Object
    /// No images are saved by the retrievr.
    /// </summary>
    public class Retrievr
    {
        private PhotoStream _photostream;
        private int _currentPhotoIndex;

        public Retrievr() : this(new EveryonesPhotoStream())
        {
        }

        public Retrievr(PhotoStream stream)
        {
            CurrentIndex = 0;            
            PhotoStream = stream;
        }

    	public PhotoStream PhotoStream
		{
			get { return _photostream; }
            set
            {
                if (value != _photostream)
                {
                    _photostream = value; 
                    //CurrentIndex = 0;
                }
            }
		}

        public int CurrentIndex
        {
            get { return _currentPhotoIndex; }
            set { _currentPhotoIndex = value; }
        }

        public Wallpapr GetNextWallpaper()
    	{
    		return new Wallpapr(_photostream[CurrentIndex++]);
    	}

//    	public Wallpapr GetRandomWallpapr()
//    	{
//    		_currentPhotoIndex = new Random(DateTime.Now.Millisecond).Next(_photostream.Count);
//			return new Wallpapr(_photostream[_currentPhotoIndex]);
//    	}
    }
}
